package com.potenza.product.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.potenza.product.domain.BFinanceProduct;
import com.potenza.product.service.IBFinanceProductService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 博天金融贷款产品Controller
 * 
 * @author ruoyi
 * @date 2022-12-14
 */
@RestController
@RequestMapping("/product")
public class BFinanceProductController extends BaseController
{
    @Autowired
    private IBFinanceProductService bFinanceProductService;

    /**
     * 查询博天金融贷款产品列表
     */
    @RequiresPermissions("product:product:list")
    @GetMapping("/list")
    public TableDataInfo list(BFinanceProduct bFinanceProduct)
    {
        startPage();
        List<BFinanceProduct> list = bFinanceProductService.selectBFinanceProductList(bFinanceProduct);
        return getDataTable(list);
    }

    /**
     * 导出博天金融贷款产品列表
     */
    @RequiresPermissions("product:product:export")
    @Log(title = "博天金融贷款产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BFinanceProduct bFinanceProduct)
    {
        List<BFinanceProduct> list = bFinanceProductService.selectBFinanceProductList(bFinanceProduct);
        ExcelUtil<BFinanceProduct> util = new ExcelUtil<BFinanceProduct>(BFinanceProduct.class);
        util.exportExcel(response, list, "博天金融贷款产品数据");
    }

    /**
     * 获取博天金融贷款产品详细信息
     */
    @RequiresPermissions("product:product:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bFinanceProductService.selectBFinanceProductById(id));
    }

    /**
     * 新增博天金融贷款产品
     */
    @RequiresPermissions("product:product:add")
    @Log(title = "博天金融贷款产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BFinanceProduct bFinanceProduct)
    {
        return toAjax(bFinanceProductService.insertBFinanceProduct(bFinanceProduct));
    }

    /**
     * 修改博天金融贷款产品
     */
    @RequiresPermissions("product:product:edit")
    @Log(title = "博天金融贷款产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BFinanceProduct bFinanceProduct)
    {
        return toAjax(bFinanceProductService.updateBFinanceProduct(bFinanceProduct));
    }

    /**
     * 删除博天金融贷款产品
     */
    @RequiresPermissions("product:product:remove")
    @Log(title = "博天金融贷款产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bFinanceProductService.deleteBFinanceProductByIds(ids));
    }
}
